<template>
  <div 
    :class="[
      'bx-dropdown-item',
      {
        'bx-dropdown-item--disabled': disabled,
        'bx-dropdown-item--divided': divided
      }
    ]"
    @click="handleClick"
  >
    <BxIcon v-if="icon" :name="icon" class="bx-dropdown-item__icon" />
    <span class="bx-dropdown-item__content">
      <slot>{{ label }}</slot>
    </span>
  </div>
</template>

<script>
import BxIcon from '../basic/BxIcon.vue'

export default {
  name: 'BxDropdownItem',
  components: {
    BxIcon
  },
  props: {
    label: {
      type: String,
      default: ''
    },
    value: {
      type: [String, Number],
      default: ''
    },
    icon: {
      type: String,
      default: ''
    },
    disabled: {
      type: Boolean,
      default: false
    },
    divided: {
      type: Boolean,
      default: false
    }
  },
  emits: ['click'],
  setup(props, { emit }) {
    const handleClick = (event) => {
      if (props.disabled) return
      emit('click', props.value, event)
    }

    return {
      handleClick
    }
  }
}
</script>

<style scoped>
.bx-dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--bx-spacing-sm);
  padding: 8px 12px;
  cursor: pointer;
  transition: all var(--bx-transition-medium);
  border-radius: var(--bx-radius-small);
  font-size: 14px;
  line-height: 1.5;
  color: var(--bx-text-primary);
  position: relative;
  z-index: 1;
}

.bx-dropdown-item:hover {
  background: var(--bx-glass-bg-hover);
}

.bx-dropdown-item--disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.bx-dropdown-item--disabled:hover {
  background: transparent;
}

.bx-dropdown-item--divided {
  border-top: 1px solid var(--bx-glass-border);
  margin-top: var(--bx-spacing-xs);
  padding-top: calc(8px + var(--bx-spacing-xs));
}

.bx-dropdown-item__icon {
  font-size: 14px;
  color: var(--bx-text-secondary);
  flex-shrink: 0;
}

.bx-dropdown-item__content {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .bx-dropdown-item {
    padding: 6px 10px;
    font-size: 13px;
  }
  
  .bx-dropdown-item__icon {
    font-size: 13px;
  }
}
</style>

